package com.zshy.base.kit.enums.language.detail;

import com.zshy.base.kit.enums.language.Iso6391LanguageEnum;
import com.zshy.base.kit.enums.language.RealLanguageTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 中文语言扩展
 *
 * @author zhouhengzhe
 * @version 1.0
 * @date 2023/9/7 15:27
 */
@Getter
@AllArgsConstructor
public enum ChinaLanguageTypeEnum {
    ZH("zh", "简体中文", RealLanguageTypeEnum.ZH_CN.getCode(), Iso6391LanguageEnum.ZH),
    ZH_CN("zh-CN", "简体中文", RealLanguageTypeEnum.ZH_CN.getCode(), Iso6391LanguageEnum.ZH),
    ZH_TW("zh-TW", "繁体中文", RealLanguageTypeEnum.ZH_TW.getCode(), Iso6391LanguageEnum.ZH),
    ZH_HK("zh-HK", "繁体中文", RealLanguageTypeEnum.ZH_TW.getCode(), Iso6391LanguageEnum.ZH),
    ZH_MO("zh-MO", "繁体中文", RealLanguageTypeEnum.ZH_TW.getCode(), Iso6391LanguageEnum.ZH),
    ZH_HANT("zh-hant", "繁体中文", RealLanguageTypeEnum.ZH_TW.getCode(), Iso6391LanguageEnum.ZH),
    ZH_HANS("zh-hans", "简体中文", RealLanguageTypeEnum.ZH_CN.getCode(), Iso6391LanguageEnum.ZH);

    /**
     * 语言标识
     */
    private final String code;

    /**
     * 描述
     */
    private final String message;

    /**
     * 实际用的语言
     */
    private final String realCode;

    /**
     * ISO语言标识
     */
    private final Iso6391LanguageEnum iso6391LanguageEnum;

    /**
     * 通过code获取实际用的语言
     *
     * @param language
     * @return
     */
    public static String getRealCodeByCode(String language) {
        for (ChinaLanguageTypeEnum value : values()) {
            if (value.getCode().equalsIgnoreCase(language)) {
                return value.getRealCode();
            }
        }
        return null;
    }
}
